RESTful API implementation for UTCP
The HTTP provider enables UTCP to interact with standard RESTful HTTP/HTTPS APIs, which are the most common type of web service. This provider supports various HTTP methods, authentication schemes, and flexible request/response handling.
HTTP providers are configured using the following JSON structure:
{ "name": "my_rest_api", "provider_type": "http", "url": "https://api.example.com/endpoint", "http_method": "POST", "content_type": "application/json", "auth": { "auth_type": "api_key", "api_key": "YOUR_API_KEY", "var_name": "X-API-Key" }, "headers": { "X-Custom-Header": "custom_value" }, "body_field": "request_body", "header_fields": ["user_id"] }
Field | Required | Description |
---|---|---|
name |
Yes | Unique identifier for the provider |
provider_type |
Yes | Must be set to "http" |
url |
Yes | Full URL to the API endpoint |
http_method |
No | HTTP method to use (default: "GET" ). Can be GET, POST, PUT, DELETE, or PATCH. |
content_type |
No | Content type header (default: "application/json" ) |
auth |
No | Authentication configuration (if required) |
headers |
No | A dictionary of static headers to include in every request |
body_field |
No | The name of a single input field to be sent as the raw request body |
header_fields |
No | A list of input fields to be sent as request headers |
HTTP providers support several authentication methods:
{ "auth": { "auth_type": "api_key", "api_key": "YOUR_API_KEY", "var_name": "X-API-Key" } }
{ "auth": { "auth_type": "bearer", "token": "YOUR_BEARER_TOKEN" } }
{ "auth": { "auth_type": "basic", "username": "your_username", "password": "your_password" } }
For HTTP providers, the tool discovery endpoint should be accessible at /utcp
on the same domain as the API. For example:
https://api.example.com/utcp
The discovery endpoint should return a UTCPManual
object as described
in the For Tool Providers section.
{ "name": "weather_api", "provider_type": "http", "url": "https://api.weather.com/v1/current", "http_method": "GET", "auth": { "auth_type": "api_key", "api_key": "your_weather_api_key", "var_name": "X-API-Key" } }
{ "name": "user_management", "provider_type": "http", "url": "https://api.example.com/users", "http_method": "POST", "content_type": "application/json", "auth": { "auth_type": "bearer", "token": "your_jwt_token" }, "headers": { "X-Client-Version": "1.0.0" } }
© 2024 Universal Tool Calling Protocol. All rights reserved.